<!--{include file='common/header.htm'}-->
<!--{include file='common/header_nav.htm'}-->
<div class="wide">
    <form action="/user/register" method="post" name="register" id="form_reg">
    <label class="label inline_block mr_b1" for="email">
        电子邮件</label>
    <input class="inputwidth" type="text" name="email" value="{$email}" id="email" maxlength="100" />
    <span id="email_error" class="errorbox">{$error.email}</span>
    <br />
    <label class="label inline_block mr_b1" for="nick">
        昵称</label>
    <input class="inputwidth" type="text" name="nick" value="{$nick}" id="nick" maxlength="20" />
    <span id="nick_error" class="errorbox">{$error.nick}</span>
    <br />
    <label class="label inline_block mr_b1" for="password">
        密码</label>
    <input class="inputwidth" type="password" name="password" value="" id="password"
        maxlength="20" />
    <span id="password_error" class="errorbox">{$error.password}</span>
    <br />
    <input type="hidden" name="register" />
    <input type="button" name="reg" id="btn_reg" value="注册" />
    </form>
</div>
<script src="/static/javascript/maxlength.js"></script>
<!--{literal}-->
<script type="text/javascript">
    $(document).ready(function () {
        $("#email").bind("propertychange", function () {
            $(this).maxlength();
        }).keydown(function () {
            $("#email_error").css("visibility", "hidden").html("");
        });
        $("#nick").bind("propertychange", function () {
            $(this).maxlength();
        }).keydown(function () {
            $("#nick_error").css("visibility", "hidden").html("");
        });

        $("#password").bind("propertychange", function () {
            $(this).maxlength();
        }).keydown(function () {
            $("#password_error").css("visibility", "hidden").html("");
        });
        $("#btn_reg").click(function () {
            hasError = false;
            var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
            var email = $("#email").val();
            if (email.length == 0) {
                $("#email_error").css("visibility", "visible").html("邮件地址不能为空");
                hasError = true;
            } else if (!emailReg.test(email)) {
                $("#email_error").css("visibility", "visible").html("邮件地址格式不正确	");
                hasError = true;
            }
            var passlen = $("#password").val().length;
            if (passlen == 0) {
                $("#password_error").css("visibility", "visible").html("密码不能为空");
                hasError = true;
            } else if (passlen < 6) {
                $("#password_error").css("visibility", "visible").html("密码长度不足");
                hasError = true;
            }
            var nick = $("#nick").val();
            var nicklen = nick.trim().length;
            //alert("\""+nick+"\":"+nicklen);
            var nickReg = /^([0-9a-zA-Z ]|[^\x00-\xff])+$/;
            if (nicklen == 0) {
                $("#nick_error").css("visibility", "visible").html("昵称不能为空");
                hasError = true;
            } else if (nicklen < 3) {
                $("#nick_error").css("visibility", "visible").html("昵称长度不能小于3个字符");
                hasError = true;
            }
            else if (!nickReg.test(nick)) {
                $("#nick_error").css("visibility", "visible").html("昵称格式不正确");
                hasError = true;
            }
            if (false == hasError) {
                $("#form_reg")[0].submit();
            }
        });
    });
</script>
<!--{/literal}-->
<!--{include file='common/footer.htm'}-->
